<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">

        <ui:define name="title">
            <h:outputText value="#{bundle.ListHorarioTitle}"></h:outputText>
        </ui:define>

        <ui:define name="body">

            <h:panelGroup id="messagePanel" layout="block">
                <p:growl />
            </h:panelGroup>

            <h:form id="formHorarioList">

                <h:panelGroup>

                    <p:dataTable id="tableHorario" value="#{horarioController.items}" var="item" 
                                 emptyMessage="#{bundle.ListHorarioEmpty}">

                        <f:facet name="header">#{bundle.ListHorarioTitle}</f:facet>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListHorarioTitle_horaInicio}"/>
                            </f:facet>
                            <h:outputText value="#{item.horaInicio}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListHorarioTitle_horaFim}"/>
                            </f:facet>
                            <h:outputText value="#{item.horaFim}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Domingo" />
                            </f:facet>
                            <p:selectBooleanButton id="domingo" value="#{item.domingo}" 
                                                   disabled="true" onLabel="Sim" offLabel="Não" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Segunda" />
                            </f:facet>
                            <p:selectBooleanButton id="segunda" value="#{item.segunda}" 
                                                   disabled="true" onLabel="Sim" offLabel="Não" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Terça"/>
                            </f:facet>
                            <p:selectBooleanButton id="terca" value="#{item.terca}" 
                                                   disabled="true" onLabel="Sim" offLabel="Não" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Quarta" />
                            </f:facet>
                            <p:selectBooleanButton id="quarta" value="#{item.quarta}" 
                                                   disabled="true" onLabel="Sim" offLabel="Não" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Quinta"/>
                            </f:facet>
                            <p:selectBooleanButton id="quinta" value="#{item.quinta}" 
                                                   disabled="true" onLabel="Sim" offLabel="Não" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Sexta"/>
                            </f:facet>
                            <p:selectBooleanButton id="sexta" value="#{item.sexta}" 
                                                   disabled="true" onLabel="Sim" offLabel="Não" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Sábado"/>
                            </f:facet>
                            <p:selectBooleanButton id="sabado" value="#{item.sabado}" 
                                                   disabled="true" onLabel="Sim" offLabel="Não" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <p:commandButton actionListener="#{horarioController.prepareCreate}" 
                                                 value="#{bundle.ListHorarioCreateLink}"
                                                 update=":formHorarioCreate:pgHorarioCreate" 
                                                 oncomplete="dialogHorarioCreate.show()"/>
                            </f:facet>
                            <p:commandButton actionListener="#{horarioController.prepareEdit}" 
                                             value="#{bundle.ListHorarioEditLink}"
                                             update=":formHorarioEdit:pgHorarioEdit" 
                                             oncomplete="dialogHorarioEdit.show()" />
                            <p:commandButton actionListener="#{horarioController.destroy}" 
                                             value="#{bundle.ListHorarioDestroyLink}" ajax="false"/>
                        </p:column>

                    </p:dataTable>
                </h:panelGroup>

            </h:form>

            <h:form id="formHorarioCreate">

                <p:dialog header="#{bundle.CreateHorarioTitle}" widgetVar="dialogHorarioCreate" resizable="false" modal="true" showEffect="slide">
                    <p:panelGrid id="pgHorarioCreate" columns="2">
                        <h:outputLabel value="#{bundle.CreateHorarioLabel_horaInicio}" for="horaInicio" />
                        <p:inputMask id="horaInicio" value="#{horarioController.selected.horaInicio}" 
                                     title="#{bundle.CreateHorarioTitle_horaFim}" 
                                     required="true" mask="99:99"
                                     requiredMessage="#{bundle.CreateHorarioRequiredMessage_horaInicio}"/>
                        <h:outputLabel value="#{bundle.CreateHorarioLabel_horaFim}" for="horaFim" />
                        <p:inputMask id="horaFim" value="#{horarioController.selected.horaFim}" 
                                     title="#{bundle.CreateHorarioTitle_horaFim}" 
                                     required="true" mask="99:99"
                                     requiredMessage="#{bundle.CreateHorarioRequiredMessage_horaInicio}"/>

                        <h:outputLabel value="Domingo" for="domingo" />
                        <p:selectBooleanButton id="domingo" value="#{horarioController.selected.domingo}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Segunda" for="segunda" />
                        <p:selectBooleanButton id="segunda" value="#{horarioController.selected.segunda}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Terça" for="terca" />
                        <p:selectBooleanButton id="terca" value="#{horarioController.selected.terca}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Quarta" for="quarta" />
                        <p:selectBooleanButton id="quarta" value="#{horarioController.selected.quarta}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Quinta" for="quinta" />
                        <p:selectBooleanButton id="quinta" value="#{horarioController.selected.quinta}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Sexta" for="sexta" />
                        <p:selectBooleanButton id="sexta" value="#{horarioController.selected.sexta}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Sábado" for="sabado" />
                        <p:selectBooleanButton id="sabado" value="#{horarioController.selected.sabado}" 
                                               onLabel="Sim" offLabel="Não" />

                        <p:commandButton actionListener="#{horarioController.create}" update=":formHorarioList:tableHorario" value="#{bundle.CreateHorarioSaveLink}" oncomplete="#{horarioController.prepareCreate}" ajax="false" />
                        <p:commandButton value="Limpar" type="reset" update=":formHorarioCreate:pgHorarioCreate" ajax="false"/>
                    </p:panelGrid>
                </p:dialog>

            </h:form>

            <h:form id="formHorarioEdit">

                <p:dialog header="#{bundle.EditHorarioTitle}" widgetVar="dialogHorarioEdit" resizable="false" modal="true" showEffect="slide">
                    <p:panelGrid id="pgHorarioEdit" columns="2">
                        <h:outputLabel value="#{bundle.EditHorarioLabel_horaInicio}" for="horaInicio" />
                        <p:inputMask id="horaInicio" value="#{horarioController.selected.horaInicio}" 
                                     title="#{bundle.EditHorarioTitle_horaFim}" 
                                     required="true" mask="99:99"
                                     requiredMessage="#{bundle.EditHorarioRequiredMessage_horaInicio}"/>
                        <h:outputLabel value="#{bundle.EditHorarioLabel_horaFim}" for="horaFim" />
                        <p:inputMask id="horaFim" value="#{horarioController.selected.horaFim}" 
                                     title="#{bundle.EditHorarioTitle_horaFim}" 
                                     required="true" mask="99:99"
                                     requiredMessage="#{bundle.EditHorarioRequiredMessage_horaInicio}"/>

                        <h:outputLabel value="Domingo" for="domingo" />
                        <p:selectBooleanButton id="domingo" value="#{horarioController.selected.domingo}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Segunda" for="segunda" />
                        <p:selectBooleanButton id="segunda" value="#{horarioController.selected.segunda}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Terça" for="terca" />
                        <p:selectBooleanButton id="terca" value="#{horarioController.selected.terca}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Quarta" for="quarta" />
                        <p:selectBooleanButton id="quarta" value="#{horarioController.selected.quarta}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Quinta" for="quinta" />
                        <p:selectBooleanButton id="quinta" value="#{horarioController.selected.quinta}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Sexta" for="sexta" />
                        <p:selectBooleanButton id="sexta" value="#{horarioController.selected.sexta}" 
                                               onLabel="Sim" offLabel="Não" />

                        <h:outputLabel value="Sábado" for="sabado" />
                        <p:selectBooleanButton id="sabado" value="#{horarioController.selected.sabado}" 
                                               onLabel="Sim" offLabel="Não" />

                        <p:commandButton actionListener="#{horarioController.update}" update=":formHorarioList:tableHorario" 
                                         value="#{bundle.EditHorarioSaveLink}" oncomplete="dialogHorarioEdit.hide()" ajax="false" />
                        <p:commandButton value="Cancelar" oncomplete="dialogHorarioEdit.hide()" ajax="false"/>
                    </p:panelGrid>
                </p:dialog>

            </h:form>

        </ui:define>
    </ui:composition>

</html>
